package com.caldremch.powerservice;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import android.view.View;
import android.view.animation.LinearInterpolator;

public class MainActivity extends AppCompatActivity {


    private PowerService.MyBinder mMyBinder;

    ServiceConnection connection = new ServiceConnection() {
        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            mMyBinder = (PowerService.MyBinder) service;
            mMyBinder.service_connect_activity();

        }

        @Override
        public void onServiceDisconnected(ComponentName name) {


        }
    };


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        LinearInterpolator x;
    }

    public void startPlay(View view) {
        Intent intent = new Intent(this, PowerService.class);
        startService(intent);
    }

    public void pausePlay(View view) {
    }

    public void stopPlay(View view) {
        Intent intent = new Intent(this, PowerService.class);
        stopService(intent);
    }

    public void startNewAct(View view) {
        startActivity(new Intent(this, MainActivity.class));
    }

    public void unbindMyService(View view) {
        Intent intent = new Intent(this, PowerService.class);
        unbindService(connection);
    }

    public void bindMyService1(View view) {
        Log.d("c", "onclc");
        Intent intent = new Intent(this, PowerService.class);
        bindService(intent, connection, BIND_AUTO_CREATE);
    }
}
